<#include "public.ftl">
package ${basePackage}.service.impl;

import com.huitu.commons.PageUtils;
import com.huitu.whht.hbszy.wrem.TestBase;
import ${basePackage}.entities.${baseClassName};
import ${basePackage}.entities.${baseClassName}Qo;
import ${basePackage}.service.I${baseClassName}${props.classNameSuffix}Service;
import com.huitu.whht.hbszy.wrem.common.annotations.SzyWremApiService;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 说明: ${tab.remarks}Service 测试用例,表名称: ${tab.tableName} <br/>
 * 日期: ${currentDate}
 * @author ${author}
 */
public class ${baseClassName}${props.classNameSuffix}ServiceImplTest extends TestBase {

    @Autowired
    @SzyWremApiService
    I${baseClassName}${props.classNameSuffix}Service ${baseInstanceName}${props.classNameSuffix}Service;

    /**
     * 根据主键查询
     */
    @Test
    public void selectByPrimaryKey() {
    //  Map<String,Object> map = ${baseInstanceName}${props.classNameSuffix}Service.updateByPrimaryKeySelective(record);
    //  Assert.assertTrue(map != null && !map.isEmpty());
    }

    /**
     * 根据条件查询
     */
    @Test
    public void selectList() {
        PageUtils.startPage(1,20);
        ${baseClassName}Qo filter = ${baseClassName}Qo.builder().build();
        List<Map<String,Object>> listAll = ${baseInstanceName}${props.classNameSuffix}Service.selectList(filter);
        Assert.assertTrue( listAll.size() <= 20);
    }

<#if props.partition??>

    /**
     * 根据条件查询最新监测数据
     */
    @Test
    public void selectLatest() {
        PageUtils.startPage(1,20);
    ${baseClassName}Qo filter = ${baseClassName}Qo.builder().build();
        List<Map<String,Object>> listAll = ${baseInstanceName}${props.classNameSuffix}Service.selectList(filter);
        Assert.assertTrue( listAll.size() <= 20);
    }
</#if>

    /**
     * 新增(null字段会被忽略)
     */
    @Test
    public void insertSelective() {
    ${baseClassName} ${baseInstanceName} = ${baseClassName}.builder().build();
<#list colList as col>
    <#if col.columnName == 'TS'>
        //record.setTs(LocalDateTime.now());
    </#if>
    <#if col.columnName == 'NT'>
        //record.setNt("根据主键按需修改(null字段会被忽略)");
    </#if>
</#list>
    // int i = ${baseInstanceName}${props.classNameSuffix}Service.insertSelective(record);
    // Assert.assertTrue( i == 1);
    }

    /**
     * 根据主键按需修改(null字段会被忽略)
     */
    @Test
    public void updateByPrimaryKeySelective() {
    ${baseClassName} ${baseInstanceName} = ${baseClassName}.builder().build();
<#list colList as col>
    <#if col.columnName == 'TS'>
        //record.setTs(LocalDateTime.now());
    </#if>
    <#if col.columnName == 'NT'>
        //record.setNt("根据主键按需修改(null字段会被忽略)");
    </#if>
</#list>
    // int i = ${baseInstanceName}${props.classNameSuffix}Service.updateByPrimaryKeySelective(record);
    // Assert.assertTrue( i == 1);
    }

    /**
     * 根据主键修改
     */
    @Test
    public void updateByPrimaryKey() {
<#list colList as col>
    <#if col.columnName == 'TS'>
        //record.setTs(LocalDateTime.now());
    </#if>
    <#if col.columnName == 'NT'>
        //record.setNt("根据主键按需修改");
    </#if>
</#list>
    // int i = ${baseInstanceName}${props.classNameSuffix}Service.updateByPrimaryKey(record);
    // Assert.assertTrue( i == 1);
    }

    /**
     * 根据主键删除
     */
    @Test
    public void deleteByPrimaryKey() {
    // int i = ${baseInstanceName}${props.classNameSuffix}Service.deleteByPrimaryKey(<@serviceMethodPKParamValues pkList=pkList funcs=funcs baseInstanceName=baseInstanceName objectName="pk"></@serviceMethodPKParamValues>);
    // Assert.assertTrue( i == 1);
    }

    /**
     * 根据主键删除
     */
    @Test
    public void deleteByFilter() {
    // ${baseClassName}Qo filter = ${baseClassName}Qo.builder().build();
    // int i = ${baseInstanceName}${props.classNameSuffix}Service.deleteByFilter(filter);
    // Assert.assertTrue( i == 1);
    }
}